package com.cym.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cym.bean.OrderBy.Direction;
import com.cym.bean.Sort;
import com.cym.model.Goods;
import com.cym.utils.ConditionAndWrapper;
import com.cym.utils.JpaHelper;

import cn.hutool.core.util.StrUtil;

@Service
public class GoodsService {
	@Autowired
	JpaHelper jpaHelper;

	public List<Goods> search(String keyword) {
		ConditionAndWrapper conditionAndWrapper = new ConditionAndWrapper();
		if (StrUtil.isNotEmpty(keyword)) {
			conditionAndWrapper.like(Goods::getTag, keyword);
		}

		return jpaHelper.findListByQuery(conditionAndWrapper, new Sort(Goods::getTag, Direction.ASC), Goods.class);
	}

}
